<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="student" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{studentHome.managed ? 'Edit' : 'Add'} Student</f:facet>


            <s:decorate id="idField" template="layout/edit.xhtml">
                <ui:define name="label">Id</ui:define>
                <h:inputText id="id"
                       required="true"
                       disabled="#{studentHome.managed}"
                          value="#{studentHome.instance.id}">
                    <a:support event="onblur" reRender="idField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>




            <s:decorate id="firstNameField" template="layout/edit.xhtml">
                <ui:define name="label">First name</ui:define>
                <h:inputText id="firstName"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{studentHome.instance.firstName}">
                    <a:support event="onblur" reRender="firstNameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="lastNameField" template="layout/edit.xhtml">
                <ui:define name="label">Last name</ui:define>
                <h:inputText id="lastName"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{studentHome.instance.lastName}">
                    <a:support event="onblur" reRender="lastNameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="passportPhotoUrlField" template="layout/edit.xhtml">
                <ui:define name="label">Passport photo url</ui:define>
                <h:inputText id="passportPhotoUrl"
                           size="100"
                      maxlength="150"
                          value="#{studentHome.instance.passportPhotoUrl}">
                    <a:support event="onblur" reRender="passportPhotoUrlField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="dateOfBirthField" template="layout/edit.xhtml">
                <ui:define name="label">Date of birth</ui:define>
                <rich:calendar id="dateOfBirth"
                       required="true"
                          value="#{studentHome.instance.dateOfBirth}" datePattern="MM/dd/yyyy" />
            </s:decorate>


            <s:decorate id="registerNumberField" template="layout/edit.xhtml">
                <ui:define name="label">Register number</ui:define>
                <h:inputText id="registerNumber"
                          value="#{studentHome.instance.registerNumber}">
                    <a:support event="onblur" reRender="registerNumberField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="rollNumberField" template="layout/edit.xhtml">
                <ui:define name="label">Roll number</ui:define>
                <h:inputText id="rollNumber"
                          value="#{studentHome.instance.rollNumber}">
                    <a:support event="onblur" reRender="rollNumberField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>







            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{studentHome.persist}"
                       disabled="#{!studentHome.wired}"
                       rendered="#{!studentHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{studentHome.update}"
                       rendered="#{studentHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{studentHome.remove}"
                      immediate="true"
                       rendered="#{studentHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Student.xhtml"
                rendered="#{studentHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty studentFrom ? 'StudentList' : studentFrom}.xhtml"
                rendered="#{!studentHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="UserAccount">
    <div class="association" id="userAccountParent">

        <h:outputText value="There is no userAccount associated with this student."
                   rendered="#{studentHome.instance.userAccount == null}"/>

        <rich:dataTable var="_userAccount"
                   value="#{studentHome.instance.userAccount}"
                rendered="#{studentHome.instance.userAccount != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="userAccountTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_userAccount.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">UserAccountname</f:facet>
                <h:outputText value="#{_userAccount.username}"/>
            </h:column>
         
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{studentHome.instance.userAccount != null ? 'changeParentuserAccount' : 'selectParentuserAccount'}" value="#{studentHome.instance.userAccount != null ? 'Change' : 'Select'} userAccount"
                       view="/UserAccountList.xhtml">
                       
                       
                <f:param name="from" value="StudentEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Course *" labelClass="required">
    <div class="association" id="courseParent">

        <h:outputText value="There is no course associated with this student."
                   rendered="#{studentHome.instance.course == null}"/>

        <rich:dataTable var="_course"
                   value="#{studentHome.instance.course}"
                rendered="#{studentHome.instance.course != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="courseTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_course.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Teacher id</f:facet>
                <h:outputText value="#{_course.teacher.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Course name</f:facet>
                <h:outputText value="#{_course.courseName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Details</f:facet>
                <h:outputText value="#{_course.details}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{studentHome.instance.course != null ? 'changeParentcourse' : 'selectParentcourse'}" value="#{studentHome.instance.course != null ? 'Change' : 'Select'} course"
                       view="/CourseList.xhtml">
                       
                       
                <f:param name="from" value="StudentEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Student previous acad detailses">
        <h:form styleClass="association" id="studentPreviousAcadDetailsesChildren">

            <h:outputText value="There are no studentPreviousAcadDetailses associated with this student."
                       rendered="#{empty studentHome.studentPreviousAcadDetailses}"/>

            <rich:dataTable value="#{studentHome.studentPreviousAcadDetailses}"
                           var="_studentPreviousAcadDetails"
                      rendered="#{not empty studentHome.studentPreviousAcadDetailses}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="studentPreviousAcadDetailsesTable">
                <rich:column sortBy="#{_studentPreviousAcadDetails.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_studentPreviousAcadDetails.id}"/>
                </rich:column>
                <rich:column sortBy="#{_studentPreviousAcadDetails.courseName}">
                    <f:facet name="header">Course name</f:facet>
                    <h:outputText value="#{_studentPreviousAcadDetails.courseName}"/>
                </rich:column>
                <rich:column sortBy="#{_studentPreviousAcadDetails.instName}">
                    <f:facet name="header">Inst name</f:facet>
                    <h:outputText value="#{_studentPreviousAcadDetails.instName}"/>
                </rich:column>
                <rich:column sortBy="#{_studentPreviousAcadDetails.phone}">
                    <f:facet name="header">Phone</f:facet>
                    <h:outputText value="#{_studentPreviousAcadDetails.phone}"/>
                </rich:column>
                <rich:column sortBy="#{_studentPreviousAcadDetails.decription}">
                    <f:facet name="header">Decription</f:facet>
                    <h:outputText value="#{_studentPreviousAcadDetails.decription}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{studentHome.managed}" id="studentPreviousAcadDetailses">
        <div class="actionButtons">
            <s:button id="addstudentPreviousAcadDetails"
                   value="Add studentPreviousAcadDetails"
                    view="/StudentPreviousAcadDetailsEdit.xhtml"
             propagation="none">
                 <f:param name="studentId"
                         value="#{studentHome.instance.id}"/>
                 <f:param name="studentPreviousAcadDetailsFrom" value="Student"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Student cerficates">
        <h:form styleClass="association" id="studentCerficatesChildren">

            <h:outputText value="There are no studentCerficates associated with this student."
                       rendered="#{empty studentHome.studentCerficates}"/>

            <rich:dataTable value="#{studentHome.studentCerficates}"
                           var="_studentCerficate"
                      rendered="#{not empty studentHome.studentCerficates}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="studentCerficatesTable">
                <rich:column sortBy="#{_studentCerficate.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_studentCerficate.id}"/>
                </rich:column>
                <rich:column sortBy="#{_studentCerficate.receivedStatus}">
                    <f:facet name="header">Received status</f:facet>
                    <h:outputText value="#{_studentCerficate.receivedStatus}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{studentHome.managed}" id="studentCerficates">
        <div class="actionButtons">
            <s:button id="addstudentCerficate"
                   value="Add studentCerficate"
                    view="/StudentCerficateEdit.xhtml"
             propagation="none">
                 <f:param name="studentId"
                         value="#{studentHome.instance.id}"/>
                 <f:param name="studentCerficateFrom" value="Student"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Parents">
        <h:form styleClass="association" id="parentsChildren">

            <h:outputText value="There are no parents associated with this student."
                       rendered="#{empty studentHome.parents}"/>

            <rich:dataTable value="#{studentHome.parents}"
                           var="_parent"
                      rendered="#{not empty studentHome.parents}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="parentsTable">
                <rich:column sortBy="#{_parent.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_parent.id}"/>
                </rich:column>
                <rich:column sortBy="#{_parent.firstName}">
                    <f:facet name="header">First name</f:facet>
                    <h:outputText value="#{_parent.firstName}"/>
                </rich:column>
                <rich:column sortBy="#{_parent.lastName}">
                    <f:facet name="header">Last name</f:facet>
                    <h:outputText value="#{_parent.lastName}"/>
                </rich:column>
                <rich:column sortBy="#{_parent.mobileNumber}">
                    <f:facet name="header">Mobile number</f:facet>
                    <h:outputText value="#{_parent.mobileNumber}"/>
                </rich:column>
                <rich:column sortBy="#{_parent.officePhone}">
                    <f:facet name="header">Office phone</f:facet>
                    <h:outputText value="#{_parent.officePhone}"/>
                </rich:column>
                <rich:column sortBy="#{_parent.email}">
                    <f:facet name="header">Email</f:facet>
                    <h:outputText value="#{_parent.email}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{studentHome.managed}" id="parents">
        <div class="actionButtons">
            <s:button id="addparent"
                   value="Add parent"
                    view="/ParentEdit.xhtml"
             propagation="none">
                 <f:param name="studentId"
                         value="#{studentHome.instance.id}"/>
                 <f:param name="parentFrom" value="Student"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Student certificate locations">
        <h:form styleClass="association" id="studentCertificateLocationsChildren">

            <h:outputText value="There are no studentCertificateLocations associated with this student."
                       rendered="#{empty studentHome.studentCertificateLocations}"/>

            <rich:dataTable value="#{studentHome.studentCertificateLocations}"
                           var="_studentCertificateLocation"
                      rendered="#{not empty studentHome.studentCertificateLocations}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="studentCertificateLocationsTable">
                <rich:column sortBy="#{_studentCertificateLocation.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_studentCertificateLocation.id}"/>
                </rich:column>
                <rich:column sortBy="#{_studentCertificateLocation.locationUrl}">
                    <f:facet name="header">Location url</f:facet>
                    <h:outputText value="#{_studentCertificateLocation.locationUrl}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{studentHome.managed}" id="studentCertificateLocations">
        <div class="actionButtons">
            <s:button id="addstudentCertificateLocation"
                   value="Add studentCertificateLocation"
                    view="/StudentCertificateLocationEdit.xhtml"
             propagation="none">
                 <f:param name="studentId"
                         value="#{studentHome.instance.id}"/>
                 <f:param name="studentCertificateLocationFrom" value="Student"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Student extra detailses">
        <h:form styleClass="association" id="studentExtraDetailsesChildren">

            <h:outputText value="There are no studentExtraDetailses associated with this student."
                       rendered="#{empty studentHome.studentExtraDetailses}"/>

            <rich:dataTable value="#{studentHome.studentExtraDetailses}"
                           var="_studentExtraDetails"
                      rendered="#{not empty studentHome.studentExtraDetailses}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="studentExtraDetailsesTable">
                <rich:column sortBy="#{_studentExtraDetails.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_studentExtraDetails.id}"/>
                </rich:column>
                <rich:column sortBy="#{_studentExtraDetails.nationality}">
                    <f:facet name="header">Nationality</f:facet>
                    <h:outputText value="#{_studentExtraDetails.nationality}"/>
                </rich:column>
                <rich:column sortBy="#{_studentExtraDetails.motherTongue}">
                    <f:facet name="header">Mother tongue</f:facet>
                    <h:outputText value="#{_studentExtraDetails.motherTongue}"/>
                </rich:column>
                <rich:column sortBy="#{_studentExtraDetails.gender}">
                    <f:facet name="header">Gender</f:facet>
                    <h:outputText value="#{_studentExtraDetails.gender}"/>
                </rich:column>
                <rich:column sortBy="#{_studentExtraDetails.numberOfSiblings}">
                    <f:facet name="header">Number of siblings</f:facet>
                    <h:outputText value="#{_studentExtraDetails.numberOfSiblings}"/>
                </rich:column>
                <rich:column sortBy="#{_studentExtraDetails.bloodGroup}">
                    <f:facet name="header">Blood group</f:facet>
                    <h:outputText value="#{_studentExtraDetails.bloodGroup}"/>
                </rich:column>
                <rich:column sortBy="#{_studentExtraDetails.remarks}">
                    <f:facet name="header">Remarks</f:facet>
                    <h:outputText value="#{_studentExtraDetails.remarks}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{studentHome.managed}" id="studentExtraDetailses">
        <div class="actionButtons">
            <s:button id="addstudentExtraDetails"
                   value="Add studentExtraDetails"
                    view="/StudentExtraDetailsEdit.xhtml"
             propagation="none">
                 <f:param name="studentId"
                         value="#{studentHome.instance.id}"/>
                 <f:param name="studentExtraDetailsFrom" value="Student"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Student emergency contacts">
        <h:form styleClass="association" id="studentEmergencyContactsChildren">

            <h:outputText value="There are no studentEmergencyContacts associated with this student."
                       rendered="#{empty studentHome.studentEmergencyContacts}"/>

            <rich:dataTable value="#{studentHome.studentEmergencyContacts}"
                           var="_studentEmergencyContact"
                      rendered="#{not empty studentHome.studentEmergencyContacts}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="studentEmergencyContactsTable">
                <rich:column sortBy="#{_studentEmergencyContact.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_studentEmergencyContact.id}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{studentHome.managed}" id="studentEmergencyContacts">
        <div class="actionButtons">
            <s:button id="addstudentEmergencyContact"
                   value="Add studentEmergencyContact"
                    view="/StudentEmergencyContactEdit.xhtml"
             propagation="none">
                 <f:param name="studentId"
                         value="#{studentHome.instance.id}"/>
                 <f:param name="studentEmergencyContactFrom" value="Student"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
